﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Negocios;

public partial class AgrupamentoVideo : System.Web.UI.Page
{
    AgruparVideoBLL aBLL = new AgruparVideoBLL();
    protected void Page_Load(object sender, EventArgs e)
    {
        GridView1.DataBind();
    }

    protected void BtGravar_Click(object sender, EventArgs e)
    {
        //Tirar quando a autenticação estiver funcionando
        Session["usuario"] = "teste";

        try
        {
            AgruparVideo a = new AgruparVideo(Convert.ToInt32(ddlVideo.SelectedValue), Convert.ToInt32(ddlGrupo.SelectedValue));
            aBLL.Insere(a);
            GridView1.DataBind();
            odsVideo.DataBind();
            ddlVideo.DataBind();
        }
        catch (Exception ex)
        {
            lbErro.Text = ex.Message;
        }
    }
    private void cancelar()
    {
        btGravar.Enabled = false;
        btCancelar.Enabled = false;
        lbErro.Text = "";
    }
    protected void btCancelar_Click(object sender, EventArgs e)
    {
        cancelar();
    }
    protected void lbRemove_Click(object sender, EventArgs e)
    {
        try
        {
            int video = Convert.ToInt32(((GridViewRow)((DataControlFieldCell)((LinkButton)sender).Parent).Parent).Cells[0].Text);
            int grupo = Convert.ToInt32(ddlGrupo.SelectedValue);
            AgruparVideo a = new AgruparVideo(video, grupo);
            aBLL.Excluir(a);
            odsVideo.DataBind();
            ddlVideo.DataBind();
            GridView1.DataBind();
        }
        catch (Exception ex)
        {
            lbErro.Text = ex.Message;
        }
    }
}
